import os

from pyautogui import doubleClick


def readLoan():
    dir = '/Users/jiufenshiren/data/accountFiles/jixin_sftp/20250806'
    listdir = os.listdir(dir)
    # listdir.sort()
    count = 0
    totalAmount = 0
    for file in listdir:
        print(file)
        if file.find('.DS_Store') == 0:
            continue
        if file.find('LOAN_DETAIL') != -1:  # 不等于-1，就是匹配到了
            # print(file)
            line_number = 0
            with open(os.path.join(dir, file), 'rb') as f:
                while True:
                    line = f.readline()
                    if not line:
                        break
                    line_number = line_number + 1
                    if line_number == 1:
                        continue
                    count = count + 1
                    loanData = line.decode()
                    split = loanData.split("|")
                    if split[2] == '':
                        continue
                    totalAmount = totalAmount + int(float(split[6]))
    print(count)
    print(totalAmount)


if __name__ == '__main__':
    readLoan()
